package model.eval;

import enums.TestPanelEnum;

import java.io.Serializable;
/*

    This file is part of Logica-Logike.

    Logica-Logike is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation version 3 of the License.

    Logica-Logike is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with Logica-Logike.  If not, see <http://www.gnu.org/licenses/>.

 */
/**
 * Clase abstracta, provee el modelo de ejercicio para los ejercicios que integran un Test;
 *
 * @author Jose Martin Rozanec;
 */
public abstract class TestExcercise implements Serializable {
    protected TestPanelEnum panelEnum;
    private Object testData;
    private Object solution;
    private int correctScore;
    private int incorrectScore;
    private boolean resolved;

    /**
     * Permite obtener los datos de ejercicio;
     *
     * @return Object;
     */
    public Object getExcerciseData() {
        return testData;
    }

    /**
     * Permite setear los datos de ejercicio;
     *
     * @param testData;
     */
    public void setExerciseData(Object testData) {
        this.testData = testData;
    }

    /**
     * Permite setear la resolucion del alumno;
     *
     * @param solution;
     */
    public void setStudentsSolution(Object solution) {
        this.solution = solution;
    }

    /**
     * Permite acceder la resolucion del alumno;
     *
     * @return Object;
     */
    public Object getStudentsSolution() {
        return solution;
    }

    /**
     * Permite conocer el TestPanelEnum que describe el panel sobre el que se ha de visualizar los datos de ejercicio;
     *
     * @return TestPanelEnum;
     */
    public TestPanelEnum getPanelEnum() {
        return panelEnum;
    }

    /**
     * Devuelve el puntaje que se obtiene al resolver el ejercicio de forma correcta;
     *
     * @return int;
     */
    public int getCorrectScore() {
        return correctScore;
    }

    /**
     * Permite setear el puntaje que se obtiene al resolver el ejercicio de forma correcta;
     *
     * @param score;
     */
    public void setCorrectScore(int score) {
        this.correctScore = score;
    }

    /**
     * Devuelve el puntaje que se descuenta al resolver el ejercicio de forma incorrecta;
     *
     * @return int;
     */
    public int getIncorrectScore() {
        return -incorrectScore;
    }

    /**
     * Permite establecer el puntaje que se descuenta al resolver el ejercicio de forma incorrecta;
     *
     * @param score;
     */
    public void setIncorrectScore(int score) {
        this.incorrectScore = Math.abs(score);
    }

    /**
     * Devuelve el puntaje obtenido;
     *
     * @return int;
     */
    public abstract int getAchievedScore();

    /**
     * Devuelve la representacion en String del ejercicio;
     *
     * @return String;
     */
    public abstract String toString();

    /**
     * Devuelve la representacion en String de la resolucion del alumno;
     *
     * @return String;
     */
    public abstract String getStudentSolutionString();

    /**
     * Returns the resolved value;
     * @return boolean;
     */
    public boolean isResolved() {
        return resolved;
    }

    /**
     * Allows to set the resolved state. If the resolved state is true it doesnt mean that the
     * exercise is resolved, but only that it was tagged as resolved;
     * @param resolved - boolean;
     */
    public void setResolved(boolean resolved) {
        this.resolved = resolved;
    }
}
